*{ Use the forum as user }*

#{fixture delete:'all', load:'test-data.yml' /}

#{selenium 'Use the forum as simple User'}
	clearSession()
	
	// Home page
	open('/')
	assertTextPresent('Still not a member ?')
	assertTextPresent('Forums')
	assertTextPresent('SysUsers help')
	assertTextPresent('About this sample application')
	assertTextPresent('7 posts in 4 topics')
	
	// Login
	clickAndWait('link=Login')
	assertTextPresent('Login')
	assertTextPresent('Email')
	assertTextPresent('Password')
	type('email', 'yop')
	type('password', 'kiki')
	clickAndWait('loginButton')
	
	// Should failed
	assertTextPresent('Bad email or bad password')
	assertValue('email', 'yop')
	assertNotValue('password', 'kiki')
	type('email', 'jojo@sampleforum.com')
	type('password', 'hello')
	clickAndWait('loginButton')
	assertTextPresent('Welcome back Jojo !')
	assertTextPresent('2 posts in 2 topics')
	assertTextNotPresent('Still not a member ?')
	
	// Go to forums
	clickAndWait('link=Forums')
	assertTextPresent('Forums')
	clickAndWait('link=About')
	assertTextPresent('Post a new topic')
	assertTextNotPresent('Administrator options')
	
	// Create a topic
	clickAndWait('link=Post a new topic')
	assertTextPresent('New topic')
	assertTextPresent('Subject')
	assertTextPresent('Content')
	type('subject', 'Yop')
	type('contentText', 'Héhé')
	clickAndWait('postTopic')
	
	// Check
	assertTextPresent('Yop')
	assertTextPresent('Héhé')
	clickAndWait('link=Jojo')
	assertTextPresent('3 posts in 3 topics')
	
	// Post a reply
	clickAndWait('link=Forums')
	clickAndWait('link=Play help')
	clickAndWait('link=I need *')
	clickAndWait('link=Reply')
	assertTextPresent('Reply to «I need help !»')
	type('contentText', 'Hoho')
	clickAndWait('postReply')
	
	// Check reply
	clickAndWait('link=Next*')
	assertTextPresent('Hoho')
	
	// Logout
	clickAndWait('link=Logout')
	assertTextPresent('been logged out')
	assertTextPresent('Still not a member ?')
	clickAndWait('link=SysUsers')
	assertTextPresent('3 users')
	
#{/selenium}